﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DotNETX.CommonWcfHost
{
    public class CommonHostController : ICommonHostController
    {
        public static CommonHost Host2Control { get; set; }

        public static System.ServiceModel.Channels.Binding ControllerBinding
        {
            get { return new System.ServiceModel.NetTcpBinding(); }
        }
        public static string CreateControllerAddress(string ip, int port)
        {
            return string.Format("net.tcp://{0}:{1}/CommonHostController", ip, port);
        }

        public IEnumerable<string> GetServiceNames()
        {
            return Host2Control.ServiceNames;
        }

        public System.ServiceModel.CommunicationState GetStatus(string name)
        {
            return Host2Control.GetStatus(name);
        }

        public bool Open(string name)
        {
            return Host2Control.Open(name);
        }

        public bool ReOpen(string name)
        {
            return ReOpen(name);
        }

        public bool Close(string name)
        {
            return Host2Control.Close(name);
        }

        public int OpenAll()
        {
            return Host2Control.OpenAll();
        }

        public int CloseAll()
        {
            return Host2Control.CloseAll();
        }

        public int CountOpened()
        {
            return Host2Control.CountOpened();
        }

        public int CountNotOpened()
        {
            return Host2Control.CountNotOpened();
        }
    }
}
